package com.runda.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.bbjob.dto.Result;
import com.bbjob.model.ExamineeScoresDetail;
import com.github.pagehelper.PageInfo;
import com.runda.query.QueryScoresDetail;
import com.runda.service.IExamineeScoresDetailService;


@Api(tags = "examieescoresdetailApi", description = "考生成绩详情管理")
@RestController
@RequestMapping(path = "examieescoresdetail", produces = "application/json;charset=utf-8")
public class ExamineeScoresDetailController {
	
	@Resource
	private IExamineeScoresDetailService examineeScoresDetailService;
	
	
	@ApiOperation(value="查看考试成绩详情", notes="查看考试成绩详情")
	@ApiImplicitParams({
			@ApiImplicitParam(name="id", value="考试成绩信息id", required=true, dataType="Integer", paramType="path"),
			@ApiImplicitParam(name="detail", value="考试成绩信息", required=true, dataType="QueryScoresDetail")	
	})
	@RequestMapping(value="list/{id}", method=RequestMethod.POST)
	public Result list(@PathVariable("id")Integer id, @RequestBody QueryScoresDetail detail) {
		
		List<ExamineeScoresDetail> data = examineeScoresDetailService.selectByParams(detail, id);
		PageInfo<ExamineeScoresDetail> pageInfo = new PageInfo<ExamineeScoresDetail>(data);
		
		return new Result(pageInfo);
	}
	
	@ApiOperation(value="保存考试成绩详情", notes="保存考试成绩详情")
	@ApiImplicitParam(name="detail", value="考试成绩详情", required=true, dataType="ExamineeScoresDetail")
	@RequestMapping(value="save", method=RequestMethod.POST)
	public Result save(@RequestBody ExamineeScoresDetail detail) {
		
		if (detail.getUniquecode() != null && !"".equals(detail.getUniquecode())) {
			
			examineeScoresDetailService.saveByScoreDetail(detail);
			
			return new Result(detail);
		} else {
			return new Result(8106, "学校唯一编码为空，无法查询学校信息");
		}
	}
}
	